package com.algorithm.排序.基于比较的排序;

import com.algorithm.排序.Sort;

public class 插入排序1_交换<E extends Comparable<E>> extends Sort<E> {
    @Override
    protected void sort() {
        for (int begin = 1; begin < array.length; begin++) {
            int  cur = begin;
            //从下标为一的地方开始比较，下标为0的元素像第一张扑克牌一样已经在手上了
            while (cur > 0 && cmp(cur, cur - 1) < 0) {
                swap(cur, cur - 1);
                cur --;
            }
        }
    }
}